var lastScrollX = 0;
var lastScrollY = 0;

function heartBeat() {
  var diffY = document.body.scrollTop;
  var diffX = document.body.scrollLeft;
  var leftD = document.getElementById("left_ad");
  var rightD = document.getElementById("right_ad");
  var rightDay_Week = document.getElementById("cele_date");
  var rightMonth = document.getElementById("cele_month");
  var rightCustom = document.getElementById("cele_self");

  if (diffY != lastScrollY) {
    percent = 1 * (diffY - lastScrollY);
    if (percent > 0)
      percent = Math.ceil(percent);
    else
      percent = Math.floor(percent);
    
    if (leftD) leftD.style.pixelTop += percent;
    if (rightD) rightD.style.pixelTop += percent;
    if (rightDay_Week) rightDay_Week.style.pixelTop += percent;
    if (rightMonth) rightMonth.style.pixelTop += percent;
    if (rightCustom) rightCustom.style.pixelTop += percent;
    lastScrollY = lastScrollY + percent;
  }

  if (diffX != lastScrollX) {
    percent = 1 * (diffX - lastScrollX );
    if (percent > 0)
      percent = Math.ceil(percent);
    else
      percent = Math.floor(percent);

    if (leftD) leftD.style.pixelLeft += percent;
	if (rightD) rightD.style.left = diffX+document.body.clientWidth-rightD.offsetWidth-20+"px";
    if (rightDay_Week) rightDay_Week.style.pixelLeft += percent;
    if (rightMonth) rightMonth.style.pixelLeft += percent;
    if (rightCustom) rightCustom.style.left = diffX+document.body.clientWidth-cele_self.offsetWidth-20+"px";
    lastScrollX = lastScrollX + percent;
  }
}

window.setInterval("heartBeat()", 60);

